<?php
	class login extends BaseController{
		public function getData($in_params){
			if((isset($in_params['registered']) && $in_params['registered'])){
				$this->template_data["message"] = "Vaša žiadosť o registráciu bola odoslaná.";		
			}
			
			if(isset($_SESSION['user'])) general::redirect('home');
			
			return;		
		}
		
		public function action_login($in_params=array()){
			//$in_params['email']
			$user=new m_user();
			$check['email']=$in_params['email'];
			$check['password']=md5($in_params['password']);
			if ($user->select('', $check)){
				$_SESSION["user"] = $user->to_array();
				general::redirect('home');
			} else{
				$this->template_data["message"] = "Zle zadané prihlasovacie údaje";
			}
		}
		
		public function action_logout($in_params=array()){
			if(isset($_SESSION["user"])){
				$this->template_data["message"] = "Boli ste úspešne odhlásený zo systému";	
			}
			session_unset();
			session_destroy();
		}	
	}
?>